//
//  JGMyBadOrderCell.m
//  JGRider
//
//  Created by faqiang feng on 2018/1/26.
//  Copyright © 2018年 ffq. All rights reserved.
//

#import "JGMyBadOrderCell.h"
@interface JGMyBadOrderCell()
@property (weak, nonatomic) IBOutlet UILabel *orderIdLab;
@property (weak, nonatomic) IBOutlet UILabel *fromAddressLab;
@property (weak, nonatomic) IBOutlet UILabel *toAddressLab;
@property (weak, nonatomic) IBOutlet UILabel *completeTimeLab;

@end
@implementation JGMyBadOrderCell

- (void)awakeFromNib {
    [super awakeFromNib];
    [self configSubViews];
}

-(void)configSubViews{
   
     self.selectionStyle=UITableViewCellSelectionStyleNone;
    self.completeTimeLab.layer.cornerRadius=AdaptedHeight(10);
    self.completeTimeLab.layer.masksToBounds=YES;
    self.completeTimeLab.layer.borderColor=HEXCOLOR(0xb3b3b3).CGColor;
    self.completeTimeLab.layer.borderWidth=1;
}

-(void)setModel:(JGOrderModel *)model{
    _model=model;
    self.orderIdLab.text=[NSString stringWithFormat:@"订单号：%@",model.orderid];
    self.fromAddressLab.text=[NSString stringWithFormat:@"取：%@",model.formaddress];
    self.toAddressLab.text=[NSString stringWithFormat:@"送：%@",model.toAddress];
    self.completeTimeLab.text=[NSString stringWithFormat:@"完成时间：%@",model.completetime];

     NSString *toAddressStr =[NSString stringWithFormat:@"送：%@",model.toAddress];
    NSString *formAddressStr = [NSString stringWithFormat:@"取：%@",model.formaddress];

    self.fromAddressLab.attributedText=[self getAttributedStringWithString:formAddressStr lineSpace:2 andColor:MainColor WithRange:NSMakeRange(0, 2)];
    self.fromAddressLab.textAlignment=NSTextAlignmentJustified;

    self.toAddressLab.attributedText=[self getAttributedStringWithString:toAddressStr lineSpace:2 andColor:SecondColor WithRange:NSMakeRange(0, 2)];
    self.toAddressLab.textAlignment=NSTextAlignmentJustified;

}

-(void)setFrame:(CGRect)frame{
    frame.origin.y+=5;
    frame.size.height-=5;
    [super setFrame:frame];
}

//设置行间距
-(NSAttributedString *)getAttributedStringWithString:(NSString *)string lineSpace:(CGFloat)lineSpace andColor:(UIColor*)color WithRange:(NSRange)colorRange {

    NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:string];
    NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
    paragraphStyle.lineSpacing = lineSpace; // 调整行间距
    NSRange range = NSMakeRange(0, [string length]);
    [attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:range];

    if (color) {
        [attributedString addAttribute:NSForegroundColorAttributeName value:color range:colorRange];
    }
    return attributedString;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
